s=input().strip()
flag=1
ans=""
s.lower()
for i in range(0,len(s)):
    if s[i]=='#':
        break
    if s[i]=='-' and ans=="":
        flag=-1
    if s[i]>='0'and s[i]<='9' or s[i]>='a' and s[i]<='f':
        ans+=s[i]
if ans!='':
    sum=int(ans, 16) * flag
    print(sum)
else:
    print("0")